import DateUtil from '../../engine/DateUtil';
import ViewBase from '../../engine/ViewBase';
import { HttpHelper } from '../../net/HttpHelper';
import { SocketClient } from '../../net/SocketClient';
import { NickNameConfig } from '../config/NickNameConfig';
import { AccountModel } from '../model/AccountModel';
import { UserModel } from '../model/UserModel';
import { UIHelper } from '../util/UIHelper';

const { ccclass, property } = cc._decorator;

@ccclass
export class ViewCreateRole extends ViewBase {

    private txtName: cc.EditBox;


    onEnable() {
        super.onEnable()

        this.txtName = this.getChild(this.node, "txtName", cc.EditBox);
        // this.txtName.string = NickNameConfig.randomName()
        this.txtName.string = AccountModel.instance.account;
        let btnOK: cc.Node = this.findChild(this.node, "btnOK")
        UIHelper.onAddEvent(btnOK, () => {
            if (this.txtName.string == "") {
                UIHelper.showTip("请输入呢称!")
                return;
            }
            SocketClient.create_user(this.txtName.string);
        });
    }

}

